import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home",
    meta: {
      title: "Home",
      hasLogin: false,
    },
    component: Home,
  },
  {
    path: "/verification",
    name: "verification",
    meta: {
      title: "verification",
      hasLogin: true,
    },
    component: () =>
      import(
        /* webpackChunkName: "ucenter" */ "../views/ucenter/IdentityVerification.vue"
      ),
  },
  {
    path: "/ucenter",
    name: "ucenter",
    meta: {
      title: "Personal center",
      hasLogin: true,
    },
    component: () =>
      import(/* webpackChunkName: "ucenter" */ "../views/ucenter/Ucenter.vue"),
  },
  {
    path: "/agen",
    name: "agen",
    meta: {
      title: "Agen",
      hasLogin: true,
    },
    component: () =>
      import(/* webpackChunkName: "ucenter" */ "../views/ucenter/Agen.vue"),
  },
  {
    path: "/Agen-Pengguna",
    name: "Agen-Pengguna",
    meta: {
      title: "Agen-Pengguna",
      hasLogin: true,
    },
    component: () =>
      import(
        /* webpackChunkName: "ucenter" */ "../views/ucenter/Agen-Pengguna.vue"
      ),
  },
  {
    path: "/Agen-Cashback",
    name: "Agen-Cashback",
    meta: {
      title: "Agen-Cashback",
      hasLogin: true,
    },
    component: () =>
      import(
        /* webpackChunkName: "ucenter" */ "../views/ucenter/Agen-Cashback.vue"
      ),
  },
  {
    path: "/Agen-lsi",
    name: "Agen-lsi",
    meta: {
      title: "Agen-lsi",
      hasLogin: true,
    },
    component: () =>
      import(/* webpackChunkName: "ucenter" */ "../views/ucenter/Agen-lsi.vue"),
  },
  {
    path: "/setPassword",
    name: "setPassword",
    meta: {
      title: "Set Password",
      hasLogin: true,
    },
    component: () =>
      import(
        /* webpackChunkName: "setPassword" */ "../views/ucenter/SetPassword.vue"
      ),
  },
  {
    path: "/resetPassword",
    name: "resetPassword",
    meta: {
      title: "Reset Password",
      hasLogin: false,
    },
    component: () =>
      import(
        /* webpackChunkName: "resetPassword" */ "../views/ucenter/ResetPassword.vue"
      ),
  },
  {
    path: "/transforPassword",
    name: "transforPassword",
    meta: {
      title: "Transfor password",
      hasLogin: true,
    },
    component: () =>
      import(
        /* webpackChunkName: "transforPassword" */ "../views/ucenter/TransforPassword.vue"
      ),
  },
  {
    path: "/authentication",
    name: "authentication",
    meta: {
      title: "Authentication",
      hasLogin: true,
    },
    component: () =>
      import(
        /* webpackChunkName: "authentication" */ "../views/ucenter/Authentication.vue"
      ),
  },
  {
    path: "/login",
    name: "login",
    meta: {
      title: "Login",
      hasLogin: false,
    },
    component: () =>
      import(/* webpackChunkName: "login" */ "../views/login/Login.vue"),
  },
  {
    path: "/register",
    name: "register",
    meta: {
      title: "Register",
      hasLogin: false,
    },
    component: () =>
      import(/* webpackChunkName: "register" */ "../views/login/Register.vue"),
  },
  {
    path: "/invitation",
    name: "invitation",
    meta: {
      title: "Invitation",
      hasLogin: true,
    },
    component: () =>
      import(
        /* webpackChunkName: "invitation" */ "../views/invitation/Invitation.vue"
      ),
  },
  {
    path: "/assetCente",
    name: "assetCente",
    meta: {
      title: "Asset Cente",
      hasLogin: true,
    },
    component: () =>
      import(
        /* webpackChunkName: "assetCente" */ "../views/assetCente/AssetCente.vue"
      ),
  },
  {
    path: "/exchangeHistory",
    name: "exchangeHistory",
    meta: {
      title: "Exchange history",
      hasLogin: true,
    },
    component: () =>
      import(
        /* webpackChunkName: "exchangeHistory" */ "../views/assetCente/ExchangeHistory.vue"
      ),
  },
  {
    path: "/exchange",
    name: "exchange",
    meta: {
      title: "Exchange",
      hasLogin: true,
    },
    component: () =>
      import(
        /* webpackChunkName: "exchange" */ "../views/assetCente/ExchangeCopy.vue"
      ),
  },
  {
    path: "/trade",
    name: "trade",
    meta: {
      title: "Trade",
      hasLogin: true,
    },
    component: () =>
      import(/* webpackChunkName: "trade" */ "../views/assetCente/Trade.vue"),
  },
  {
    path: "/withdrawal",
    name: "withdrawal",
    meta: {
      title: "Withdrawal",
      hasLogin: true,
    },
    component: () =>
      import(
        /* webpackChunkName: "withdrawal" */ "../views/assetCente/Withdrawal.vue"
      ),
  },
  {
    path: "/withdrawalHistory",
    name: "withdrawalHistory",
    meta: {
      title: "Withdrawal History",
      hasLogin: true,
    },
    component: () =>
      import(
        /* webpackChunkName: "withdrawalHistory" */ "../views/assetCente/WithdrawalHistory.vue"
      ),
  },
  {
    path: "/recharge",
    name: "recharge",
    meta: {
      title: "Recharge",
      hasLogin: true,
    },
    component: () =>
      import(
        /* webpackChunkName: "recharge" */ "../views/assetCente/Recharge.vue"
      ),
  },
  {
    path: "/orderWay",
    name: "orderWay",
    meta: {
      title: "Recharge",
      hasLogin: true,
    },
    component: () =>
      import(
        /* webpackChunkName: "recharge" */ "../views/assetCente/OrderWay.vue"
      ),
  },
  {
    path: "/orderPay",
    name: "orderPay",
    meta: {
      title: "Recharge",
      hasLogin: true,
    },
    component: () =>
      import(
        /* webpackChunkName: "recharge" */ "../views/assetCente/OrderPay.vue"
      ),
  },
  {
    path: "/rechargeHistory",
    name: "rechargeHistory",
    meta: {
      title: "Recharge history",
      hasLogin: true,
    },
    component: () =>
      import(
        /* webpackChunkName: "rechargeHistory" */ "../views/assetCente/RechargeHistory.vue"
      ),
  },
  {
    path: "/search",
    name: "search",
    meta: {
      title: "Search",
      hasLogin: true,
    },
    component: () =>
      import(/* webpackChunkName: "search" */ "../views/search/Search.vue"),
  },
  {
    path: "/message",
    name: "message",
    meta: {
      title: "Message",
      hasLogin: true,
    },
    component: () =>
      import(/* webpackChunkName: "message" */ "../views/message/Message.vue"),
  },
  {
    path: "/helpCenter",
    name: "helpCenter",
    meta: {
      title: "Help Center",
      hasLogin: false,
    },
    component: () =>
      import(
        /* webpackChunkName: "helpCenter" */ "../views/ucenter/HelpCenter.vue"
      ),
  },
  {
    path: "/phoneNumber",
    name: "phoneNumber",
    meta: {
      title: "Help Center",
      hasLogin: false,
    },
    component: () =>
      import(
        /* webpackChunkName: "phoneNumber" */ "../views/login/PhoneNumber.vue"
      ),
  },
  {
    path: "/serviceAgreement",
    name: "serviceAgreement",
    meta: {
      title: "Service Agreement",
      hasLogin: false,
    },
    component: () =>
      import(
        /* webpackChunkName: "phoneNumber" */ "../views/login/ServiceAgreement.vue"
      ),
  },
  {
    path: "/privacyPolicy",
    name: "privacyPolicy",
    meta: {
      title: "Privacy Policy",
      hasLogin: false,
    },
    component: () =>
      import(
        /* webpackChunkName: "phoneNumber" */ "../views/login/PrivacyPolicy.vue"
      ),
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

// router.beforeResolve((to, from, next) => {
//   document.title = to.meta.title;
//   if (to.meta.hasLogin) {
//     let TOKEN = localStorage.getItem('TOKEN');
//     if (TOKEN) {
//       next()
//     } else {
//        next()
//      router.push('/login')
//     }
//   } else {
//     next()
//   }
// })

export default router;
